package zhihui.mobile.manager.pay;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import zhihui.mobile.config.Config;
import zhihui.mobile.interfaces.net.IHttpCallBackListener;
import zhihui.mobile.manager.IManager;
import zhihui.mobile.net.HttpUtils;

/**
 * Created by 张公铭 on 2017/9/10 0010.
 */
public class PayManager implements IManager
{
    private static PayManager manager;

    public static int wx_pay = 0;   //默认下单状态，1：成功，-1失败

    private PayManager()
    {

    }

    private synchronized static void created()
    {
        if (manager == null)
        {
            manager = new PayManager();
        }
    }

    public static PayManager getInstance()
    {
        if (manager == null)
        {
            created();
        }
        return manager;
    }

    /**
     * 支付宝
     */
    public void ilpay(IHttpCallBackListener listener, String orderId, int pay_money)
    {
        Map<String, String> params = new HashMap<>();
        params.put("service", "org.zhmm.app.api.pay.AliPay");
        params.put("method", "creatOrder");

        List<Object> list = new ArrayList<>();
        list.add(orderId);
        list.add(pay_money);
        HttpUtils.postAes(Config.URL, params, list, listener);
    }

    public void weixin(IHttpCallBackListener listener, String orderId, int pay_money)
    {
        Map<String, String> params = new HashMap<>();
        params.put("service", "org.zhmm.app.api.pay.WechatPay");
        params.put("method", "unifiedOrder");

        List<Object> list = new ArrayList<>();
        list.add(orderId);
        list.add(pay_money);
        HttpUtils.postAes(Config.URL, params, list, listener);
    }

    @Override
    public void clear()
    {

    }
}
